Skip to content

Arhosseini77/Brand_Attention

Repository files navigation


Brand Attention

This repo contains the official implementation for the paper: Brand Visibility in Packaging: A Deep Learning Approach for Logo Detection, Saliency-Map Prediction, and Logo Placement Analysis

Paper . Project Page . Dataset



Brand-Attention Module

Installation

Install Pytorch with :

pip install torch==1.12.1+cu116 torchvision==0.13.1+cu116 torchaudio==0.12.1 --extra-index-url https://download.pytorch.org/whl/cu116

Install the requirements with:

pip install -r requirements.txt

Download weights:

mkdir weights
cd weights
gdown 1gGP4X_lwyd8TlxKeaYfj10mSmDPqrAeT  # Logo-Detection-Yolov8
gdown 1urHK0MGb1aaI3moogltngyALHlyuJ4lj  # ECT-SAL weights
cd ..
cd saliency_prediction
mkdir pretrained_models
cd pretrained_models
gdown 1PDdlznKsJ8VDP4ATGY1TdxN0CJ2WnTJk  # Resnet 50 pretrained weight
cd ..
cd ..

Brand-Logo Detection

Description

This module focuses on detecting brand logos in images using the YOLOv8 model. It utilizes two datasets for training: FoodLogoDet-1500 and LogoDet-3K.

Inference

You can use the following command to run the brand logo detection code:

python main_detection_yolov8.py --model="weights/Logo_Detection_Yolov8.pt" --image="test_images/test.jpg" --save-result
  • If you want to visualize the detection results, include the --save-result flag in the command.

Result

Original Image Brand Logo Detection Result
Original Image Brand Logo Detection

ECT-SAL

ECT-SAL

Description

This module is designed for predicting saliency maps of images, particularly suited for use in ads and packaging. Model leverages the ECSAL dataset for training. You can find the dataset here.

Inference

  • For saliency map prediction, it is essential to provide a corresponding text map. Use the DBNET++ model available here to generate accurate text maps for improved saliency predictions.

Run the script:

python main_saliency_prediction.py --img_path path/to/your/image.jpg --weight_path "weights/ECT_SAL.pth" --tmap path/to/test_text_map_image.jpg --output_path path/to/output/directory

Training

To train your dataset on the ECT-SAL model, follow the instructions provided in the ECT-SAL README.

Result

Original Image Saliency Map
Original Image Saliency Map

Brand-Attention

The Brand Attention Module is a component designed to assess the visibility and attention of a brand within advertisement and packaging images. It combines logo detection and saliency map prediction techniques to quantify the presence and prominence of a brand in a given image.

Inference

  • For saliency map prediction, it is essential to provide a corresponding text map. Use the DBNET++ model available here to generate accurate text maps for improved saliency predictions.
python main_brand_attention.py --img_path path/to/input_image.jpg --tmap path/to/text_map.jpg
  • If the detection is accurate and aligns with the brand logo, press 1 to confirm.

  • In cases where adjustments are needed or discrepancies exist, press 2 to signify the need for refinement.

  • For refinement, use the interactive feature to draw new bounding boxes (bboxes) directly on the image. This hands-on approach allows for precise customization of logo localization.

Result

Input Image
Brand-Attention Score: 23.54

Advertisement image object Attention

This Module is a component designed to assess the visibility and attention of any object you want within advertisement and packaging images. It saliency map prediction techniques to quantify the presence and prominence of that object in a given image.

Inference

  • For saliency map prediction, it is essential to provide a corresponding text map. Use the DBNET++ model available here to generate accurate text maps for improved saliency predictions.
python main_object_attention.py --img_path path/to/input_image.jpg --tmap path/to/text_map.jpg
  • draw bounding boxes around objects of interest, press the Enter key to calculate and obtain the attention score for the selected objects.

Result

Input Image BBox Selected
Input Image BBox Selected
Object Attention Score 11.22%

Acknowledgement

We thank the authors of Transalnet, DBNET, Efficient-Attention for their code repositories.

Citation

@article{hosseini2024brand,
  title={Brand Visibility in Packaging: A Deep Learning Approach for Logo Detection, Saliency-Map Prediction, and Logo Placement Analysis},
  author={Hosseini, Alireza and Hooshanfar, Kiana and Omrani, Pouria and Toosi, Reza and Toosi, Ramin and Ebrahimian, Zahra and Akhaee, Mohammad Ali},
  journal={arXiv preprint arXiv:2403.02336},
  year={2024}
}

About

Brand Visibility in Packaging: A Deep Learning Approach for Logo Detection, Saliency-Map Prediction, and Logo Placement Analysis

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages